package com.example.myapplication.ui.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.example.myapplication.R;
import com.example.myapplication.base.BaseRlvAdapter;
import com.example.myapplication.bean.SystemsBean;
import com.example.myapplication.swdget.FlowLayout;

import java.util.List;

public class SystemsAdapter extends BaseRlvAdapter<SystemsBean.DataBean> {

    public SystemsAdapter(Context context, List<SystemsBean.DataBean> list) {
        super(context, list);
    }

    @Override
    protected void bindData(BaseViewHolder holder, SystemsBean.DataBean dataBean) {
        FlowLayout fl = (FlowLayout) holder.itemView;
        List<SystemsBean.DataBean.ChildrenBean> children = dataBean.getChildren();
        for (int i = 0; i < children.size(); i++) {
            SystemsBean.DataBean.ChildrenBean childrenBean = children.get(i);
            TextView view = (TextView) LayoutInflater.from(mContext).inflate(R.layout.item_laber, null);
            view.setText(childrenBean.getName());
            fl.addView(view);
            //点击事件
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Log.d("TAG", "onClicksss: ");
                }
            });
        }
    }

    @Override
    protected int getLayout() {
        return R.layout.item_systems;
    }
}
